let initState = {
    num: 0
}

function reducer(state = initState, action) {
    let newState = Object.assign({}, state);
    const { type, payload } = action;
    switch (type) {
        case 'increment':
            newState.num += payload;
            break;
        case 'decrement':
            newState.num -= payload;
            break;
        default:
            break;
    }
    return newState;
}

export default reducer